import junit.framework.TestCase;

/**
 * Testing for proper functionality for method updatePlayerTest in class Event
 * @author Alan Marvel
 */
public class UpdatePlayerTest extends TestCase {
	
	private static final int HEALTHY = 0, SICK = 1, DEAD = 2;
	
	//Event event = new Event(null, null, party, leader, null);
	
	 public void testHealthyToSick()
	 {
		 PartyMember party[] = getParty();
		 PartyLeader leader = getLeader();
		 Event event = new Event(null, null, party, leader, null);
		 
		 assertEquals(party[3].getStatus(), HEALTHY);
		 event.updatePlayer(HEALTHY, SICK);
		 assertEquals(SICK, party[3].getStatus());
		 
		 assertEquals(party[2].getStatus(), HEALTHY);
		 event.updatePlayer(HEALTHY, SICK);
		 assertEquals(SICK, party[2].getStatus());
		 
		 assertEquals(party[1].getStatus(), HEALTHY);
		 event.updatePlayer(HEALTHY, SICK);
		 assertEquals(SICK, party[1].getStatus());
		 
		 assertEquals(party[0].getStatus(), HEALTHY);
		 event.updatePlayer(HEALTHY, SICK);
		 assertEquals(SICK, party[0].getStatus());
		 
		 assertEquals(leader.getStatus(), HEALTHY);
		 event.updatePlayer(HEALTHY, SICK);
		 assertEquals(SICK, leader.getStatus());
		 
		 assertEquals(party[0].getStatus(), SICK);
		 assertEquals(party[1].getStatus(), SICK);
		 assertEquals(party[2].getStatus(), SICK);
		 assertEquals(party[3].getStatus(), SICK);
	 }
	 
	 public void testSickToDead()
	 {
		 PartyMember party[] = getParty();
		 PartyLeader leader = getLeader();
		 Event event = new Event(null, null, party, leader, null);
		 
		 assertEquals(party[3].getStatus(), HEALTHY);
		 event.updatePlayer(HEALTHY, SICK);
		 event.updatePlayer(SICK, DEAD);
		 assertEquals(DEAD, party[3].getStatus());
		 
		 assertEquals(party[2].getStatus(), HEALTHY);
		 event.updatePlayer(HEALTHY, SICK);
		 event.updatePlayer(SICK, DEAD);
		 assertEquals(DEAD, party[2].getStatus());
		 
		 assertEquals(party[1].getStatus(), HEALTHY);
		 event.updatePlayer(HEALTHY, SICK);
		 event.updatePlayer(SICK, DEAD);
		 assertEquals(DEAD, party[1].getStatus());
		 
		 assertEquals(party[0].getStatus(), HEALTHY);
		 event.updatePlayer(HEALTHY, SICK);
		 event.updatePlayer(SICK, DEAD);
		 assertEquals(DEAD, party[0].getStatus());
		 
		 assertEquals(leader.getStatus(), HEALTHY);
		 event.updatePlayer(HEALTHY, SICK);
		 event.updatePlayer(SICK, DEAD);
		 assertEquals(DEAD, leader.getStatus());
		 
		 assertEquals(party[0].getStatus(), DEAD);
		 assertEquals(party[1].getStatus(), DEAD);
		 assertEquals(party[2].getStatus(), DEAD);
		 assertEquals(party[3].getStatus(), DEAD);
	 }
	 
	 public void testSickToHealthy()
	 {
		 PartyMember party[] = getParty();
		 PartyLeader leader = getLeader();
		 Event event = new Event(null, null, party, leader, null);
		 
		 for (int i = 0; i < party.length; i++)
			 party[i].setStatus(SICK);
		 leader.setStatus(SICK);
		 
		 assertEquals(party[0].getStatus(), SICK);
		 assertEquals(party[1].getStatus(), SICK);
		 assertEquals(party[2].getStatus(), SICK);
		 assertEquals(party[3].getStatus(), SICK);
		 assertEquals(leader.getStatus(), SICK); 
		 
		 event.updatePlayer(SICK, HEALTHY);
		 event.updatePlayer(SICK, HEALTHY);
		 event.updatePlayer(SICK, HEALTHY);
		 event.updatePlayer(SICK, HEALTHY);
		 event.updatePlayer(SICK, HEALTHY);
		 
		 assertEquals(party[0].getStatus(), HEALTHY);
		 assertEquals(party[1].getStatus(), HEALTHY);
		 assertEquals(party[2].getStatus(), HEALTHY);
		 assertEquals(party[3].getStatus(), HEALTHY);
		 assertEquals(leader.getStatus(), HEALTHY);
	 }
	 
	 public void testAssortedStatus()
	 {
		 PartyMember party[] = getParty();
		 PartyLeader leader = getLeader();
		 Event event = new Event(null, null, party, leader, null);
		 
	 } 
	
	 public PartyMember[] getParty()
	 {
		 PartyMember party[] = 
			{
				new PartyMember("zero"),
				new PartyMember("one"),
				new PartyMember("two"),
				new PartyMember("three")
			};
		 return party;
	 }
	 
	 public PartyLeader getLeader()
	 {
		 return new PartyLeader("leader", new Farmer());
	 }
} 